<template>
  <div>
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      style="width: 100%"
      border
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column type="index" width="55" label="ID" />
      <el-table-column
        v-if="columns.visible('amount')"
        :show-overflow-tooltip="true"
        prop="amount"
        label="数额"
      />
      <el-table-column
        v-if="columns.visible('type')"
        :show-overflow-tooltip="true"
        prop="type"
        label="方向全部"
      >
        <template slot-scope="scope">
          <div v-if="scope.row.type == 1">充值</div>
          <div v-if="scope.row.type == 2">提现</div>
        </template>
      </el-table-column>
      <el-table-column
        v-if="columns.visible('coinCode')"
        :show-overflow-tooltip="true"
        prop="coinCode"
        label="币code"
      />
      <!-- <el-table-column
        v-if="columns.visible('node')"
        :show-overflow-tooltip="true"
        prop="node"
        label="区块"
      /> -->
      <el-table-column
        v-if="columns.visible('createTime')"
        prop="createTime"
        :show-overflow-tooltip="true"
        label="创建时间"
      >
        <template slot-scope="scope">{{
          parseTime(scope.row.createTime)
        }}</template>
      </el-table-column>
      <el-table-column
        v-if="columns.visible('status')"
        :show-overflow-tooltip="true"
        prop="status"
        label="状态"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.type == 2">{{
            {
              1: "审核中",
              2: "审核通过",
              3: "失败",
              4: "已提现发送",
              4: "撤销",
            }[scope.row.status]
          }}</span>
          <span v-if="scope.row.type == 1">{{
            {
              2: "充值中",
              3: "充值成功",
            }[scope.row.status]
          }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination />
  </div>
</template>

<script>
import CRUD, { presenter, header, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import { isvalidPhone } from '@/utils/validate'
import { closeOrderPaid, closeOrderPaying } from '../../../api/order'
// crud交由presenter持有
const defaultCrud = CRUD({
  url: '/user/asset/transaction',
  title: '充提记录'
})
export default {
  name: 'Fillingrecord',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(defaultCrud), header(), crud()],
  props: ['userId'],
  data() {
    return {
      params: {},
      permission: {
        add: ['admin'],
        edit: ['admin'],
        del: ['admin']
      }
    }
  },
  created() {},
  methods: {
    [CRUD.HOOK.beforeReset]() {
      this.params = {}
    },
    [CRUD.HOOK.beforeRefresh](crud) {
      const { date } = this.params
      if (date) {
        const [startDate, endDate] = date
        crud.query.startDate = startDate
        crud.query.endDate = endDate
        crud.query.userId = this.userId
        crud.query.type = null
        crud.query.status = null
      } else {
        crud.query.startDate = ''
        crud.query.endDate = ''
        crud.query.userId = this.userId
        crud.query.type = null
        crud.query.status = null
      }
    },
    [CRUD.HOOK.beforeToEdit](crud) {
      crud.form.parentAccount = crud.form.parentPhone
    }
  }
}
</script>
